package com.sgb.member.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.sgb.member.BR;
import com.sgb.member.R;
import com.sgb.member.databinding.ItemInviteMemberRecordBinding;
import com.sgb.member.entity.MemberAuditBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public  class MemberInviteRecordAdapter extends BaseRecycleAdapter<MemberAuditBean> {

    private final int mCurPage;

    public MemberInviteRecordAdapter(Context context, List<MemberAuditBean> datas, int curPage) {
        super(context, R.layout.item_invite_member_record, datas);
        mCurPage = curPage;
    }
    @Override
    public void onBindViewHolder(ItemViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        String companyLogo = datas.get(position).getLogo();
        ImageView quality_member_logo = holder.itemView.findViewById(R.id.quality_member_logo);
        Glide.with(context).load(companyLogo).placeholder(R.drawable.member_icon_company_logo).error(R.drawable.member_icon_company_logo).into(quality_member_logo);
    }
    @Override
    public void convert(ItemViewHolder holder, final MemberAuditBean entity) {
        holder.setBinding(BR.viewModel, entity);
        holder.setBinding(BR.curPage, mCurPage);
        ItemInviteMemberRecordBinding binding = (ItemInviteMemberRecordBinding) holder.getmBinding();
        binding.tvInvite.setOnClickListener(v -> itemCallBack.againInvite(entity));
        binding.tvInvite.setVisibility(View.GONE);
        // status 状态1.待处理2.通过3.拒绝
        switch (entity.getStatus()) {
            case 1:
                binding.ivStatus.setImageResource(R.mipmap.member_icon_dsh);
                break;
            case 2:
                binding.ivStatus.setImageResource(R.mipmap.member_icon_passed);
                break;
            case 3:
                binding.ivStatus.setImageResource(R.mipmap.member_icon_wtg);
                binding.tvInvite.setVisibility(View.VISIBLE);
                break;
        }
        binding.ll.setOnClickListener(v -> itemCallBack.onItemClick(entity));
    }

    private ItemCallBack itemCallBack;

    public void setItem2CallBack(ItemCallBack itemCallBack) {
        this.itemCallBack = itemCallBack;
    }

    public interface ItemCallBack {
        void onItemClick(MemberAuditBean bean);
        void againInvite(MemberAuditBean bean);
    }



}
